import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;

class Student{
	public String name;
	public String fNomer;
	public int course;
	public double meanScore;

	public String toString(){
		
		return name+'^'+fNomer+'^'+course+'^'+meanScore+"\n";
	}
	
}

public class e03 {

	RandomAccessFile raf;
	
	public e03() throws FileNotFoundException{
		raf = new RandomAccessFile("students.txt", "rw");
	}
	
	public void add(Student s) throws IOException{
		raf.writeUTF(s.toString());
	}

	public Student read(int el) throws IOException{
		String s = null;
		//for (int i = 0;i<el;i++){
		raf.seek(-1);
		s=raf.readUTF();
		//}
		
		System.out.println(s);
		
		return null;
		
	}
	
	public static void main(String[] args) throws IOException {
	
		Student a = new Student();
		a.name="Pesho";
		a.fNomer="1234";
		a.course=1;
		a.meanScore=3.5;

		Student b = new Student();
		b.name="Ivan";
		b.fNomer="1235";
		b.course=1;
		b.meanScore=4.5;

		e03 c=new e03();
		c.add(a);
		c.add(b);
		
		c.read(1);
		
		c.raf.close();
	}	
}
